package com.homegoods.area.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.homegoods.area.R;
import com.homegoods.classify.model.TestBean.DatasBean.AddressListBean;
import com.kedll.library.adapter.ExpandListEntity;
import com.kedll.library.adapter.MyExpandableListAdapter;

import java.util.List;

/**
 * @author slj
 * @date 2015/2/12
 */
public class HotCitiesExpandListAdapter extends MyExpandableListAdapter<AddressListBean> {
    public HotCitiesExpandListAdapter(Context context, List<ExpandListEntity<AddressListBean>> expandListEntities) {
        super(context, expandListEntities);
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.expandable_listview_group, null);
        }
        final TextView group = (TextView) convertView;
        group.setText(getGroup(groupPosition));

        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.area_hot_cities_child, null);
        }
        final TextView child = (TextView) convertView;
        child.setText(getChild(groupPosition, childPosition).toString());
        return convertView;
    }
}
